package com.example.springboot.controller;

import cn.hutool.core.bean.BeanUtil;
import com.example.springboot.common.Result;
import com.example.springboot.domain.po.Account;
import com.example.springboot.domain.po.Record;
import com.example.springboot.domain.po.User;
import com.example.springboot.service.AccountService;
import com.example.springboot.service.RecordService;
import com.example.springboot.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author：伐柯梦姝
 * @Package：com.example.springboot.controller
 * @Project：springboot
 * @name：AccountController
 * @Date：2025/2/5 10:28
 * @Filename：AccountController
 * @for:
 */
@Api(tags = "预约记录接口")
@RestController
@CrossOrigin
@RequestMapping("/record")
public class RecordController {
    @Resource
    private RecordService recordService;


    //    查询所有数据
    @GetMapping("/alldata")
    public Result getData(){

        return Result.success(recordService.GetAll());

    }

    /**
     * 新增预约记录接口
     */
    @PostMapping
    public Result recordRegister(@RequestBody Record record){

        return Result.success(recordService.recordRegister(record));

    }

    /**
     * 描述：根据ID删除
     */
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        recordService.delete(id);
        return Result.success();
    }

    /**
     * 描述：分页查询
     */
    @PostMapping("/page")
    public Result page(@RequestBody Record search,
                       @RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "5") Integer pageSize) {
        return Result.success(recordService.findPage(search, pageNum, pageSize));
    }

    /**
     * 编辑预约记录信息接口
     */
    @PostMapping("/edit")
    public Result recordEdit(@RequestBody Record record){

        return Result.success(recordService.recordEdit(record));
    }

}
